//编辑展开关闭
var aSafeEditBtn = document.getElementsByClassName('safe-edit-btn');
var aSafeForm = document.getElementsByClassName('safe-form');
for(var i = 0;i<aSafeEditBtn.length;i++){
	aSafeEditBtn[i].index = i;
	aSafeEditBtn[i].onclick = function(){
		if(aSafeForm[this.index].style.display === 'none'){
			aSafeForm[this.index].style.display = 'block';
			this.style.color = '#333';
		}
		else{
			aSafeForm[this.index].style.display = 'none';
			this.style.color = '#1966FF';
		}
	}
}

//验证码倒计时
var oCodeBtn = document.getElementsByClassName('form-tel-code')[0];
function countdown(){
	var status = 2;
	if(status == 0){
		console.log('发送失败');
	}
	else if(status == 1){
		console.log('发送成功');
		var timer = null,time = 3;
		oCodeBtn.innerHTML = time + 's'+ '后重试';
		oCodeBtn.style.background = '#e2e2e2';
		oCodeBtn.style.color = '#333';
		timer = setInterval(function(){
			if(time){
				time--;
				oCodeBtn.innerHTML = time + 's' + '后重试';
				oCodeBtn.onclick = function(){
					return false;
				}
			}
			else{
				oCodeBtn.style.background = '#1966FF';
				oCodeBtn.style.color = '#fff';
				oCodeBtn.innerHTML = '发送验证码';
				clearInterval(timer);
				oCodeBtn.onclick = function(){
					countdown();
				}
			}	
		},1000)
	}
	else if(status == 2){
		console.log('发送已上限');
	}
	else{
		console.log('其它错误');
	}
}
oCodeBtn.onclick = function(){
	countdown();
}